<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios练习</title>
</head>
<body>

    <!-- 导入axios文件 -->
    <script src="../js/axios.js"></script>
    <script>
        axios.get("http://localhost:8090/user/getUserById",{
            params: {
                id: 1
            }
        }).then(result=>{
            console.log(result.data)
        })
    </script>

    <script>
        async function getUser() {
            // 通过await可以直接获取返回值
            const result = await axios.get("http://localhost:8090/user/getUserById",{
                params: {id: 1}
            })
            console.log("11111")
            console.log(result.data)
        }
        // 调用函数
        getUser()
    </script>
    <script>
        async function getUser2() {
            // 通过await可以直接获取返回值
            const {data: result} = await axios.get("http://localhost:8090/user/getUserById",{
                params: {id: 3}
            })
            console.log("解构赋值")
            console.log(result)
        }
        // 调用函数
        getUser2()



    </script>

</body>
</html>